# -*- coding: utf-8 -*-
# @Time    : 2024/8/1 9:40
# @Author  : Jonny
# @File    : LuckUserAgentHelperUtils.py
# @Describe: 设备辅助类

class LuckUserAgentHelperUtils(object):

    def get_device_type(self, request):
        user_agent = request.headers.get('User-Agent')
        # 检查 user_agent 是否为 None
        if user_agent is not None:
            # 将 user_agent 转换为小写，忽略大小写进行判断
            user_agent = user_agent.lower()
            if "iphone" in user_agent or "android" in user_agent:
                return "Mobile"
            else:
                return "Computer"
        else:
            # 如果没有 User-Agent 字段，默认返回 Computer
            return "Computer"
